import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @ClassName JsonTest
 * @Deacription TODO
 * @Author wushumin
 * @Date 2021-06-22 17:48
 * @Version 1.0
 **/
public class JsonTest {
    public static void main(String[] args) {
        WordCount.Person fred = new WordCount.Person("Fred", 9);
        System.out.println(JSON.toJSONString(fred));
        testMap();
    }
    public static void testMap(){
        List<Map<String, Object>> data = new ArrayList<>();
        Map<String,Object> da = new HashMap<>();
        da.put("dimension_name","xx");
        da.put("indicator_table","yyy");
        da.put("indicator_code","zz");
        da.put("dimension_code","xx");
        da.put("indicator_biz_table","xx");
        da.put("id",12);
        data.add(da);
        Map<Long, RichSourceTest.Indicator> dataMap = data.stream()
                .filter(item -> item.get("dimension_name") != null && item.get("indicator_table") != null)
                .map(item -> new RichSourceTest.Indicator(Long.valueOf(item.get("id").toString()),
                        item.get("indicator_code").toString(), item.get("dimension_code").toString(),
                        item.get("dimension_name").toString(), item.get("indicator_table").toString(),
                        item.get("indicator_biz_table").toString())
                ).collect(Collectors.toMap(item -> item.getId(), item -> item));
        System.out.println(dataMap);
    }
}
